package com.mayisoftware.mayioa.business.staff.impl.serviceImpl;

import com.mayisoftware.mayioa.business.staff.api.domain.StaffUploadInfo;
import com.mayisoftware.mayioa.business.staff.api.domain.StaffUploadSearchInfo;
import com.mayisoftware.mayioa.business.staff.api.service.IStaffUploadService;
import com.mayisoftware.mayioa.business.staff.impl.dao.StaffUplodMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Service
public class StaffUploasdServiceImpl implements IStaffUploadService {

    @Autowired
    private StaffUplodMapper importMapper;


    @Override
    public int insertImportOneRecord(StaffUploadInfo uploadInfo) {
        return importMapper.insertImportOneRecord(uploadInfo);
    }

    @Override
    public List<StaffUploadInfo> queryRecordList(StaffUploadSearchInfo uploadInfo) {
        return importMapper.selectRecordList(uploadInfo);
    }

    @Override
    public List<StaffUploadInfo> queryRecordListById(String recordId) {
        return importMapper.selectRecordListById(recordId);
    }

    @Override
    public List<StaffUploadInfo> queryRecordListNeedParse() {
        return importMapper.selectRecordListNeedParse();
    }

    @Override
    public int editInputRecord(StaffUploadInfo record) {
        return importMapper.updateInputRecord(record);
    }

    @Override
    public String getCheckPeriod(Date invalidDate) {

        String period = "";
        Calendar ca = Calendar.getInstance();

        ca.setTime(invalidDate);
        int month = ca.get(Calendar.MONTH);//第几个月
        int year = ca.get(Calendar.YEAR);//年份数值

        period+=year+"H";
        if (month<=6){
            period+=1;
        }else{
            period+=2;
        }

        return period;
    }

    @Override
    public List<StaffUploadInfo> queryRecordList1(StaffUploadInfo record) {

        return null;
    }

    @Override
    public List<StaffUploadInfo> queryRecordListById1(String id) {
        return importMapper.selectRecordListById(id);
    }
}
